// 修正Drill_LayerCamera、YEP_X_ActSeqPack3的镜头功能会一起缩放、平移图片的bug。（强行校正刷新图片尺寸和坐标）

Sprite_Picture.prototype.updatePosition = function() {
    const picture = this.picture();
    const picX = Math.floor(picture.x());
    const picY = Math.floor(picture.y());
    this.x = picX;
    this.y = picY;
    // 战斗中：YEP_X_ActSeqPack3
    if($gameParty.inBattle()) {
        if(ConfigManager.battleCamera){
            var zoom = $gameScreen.zoomScale();
            var clamp = BattleManager.cameraClamp();
            const spritesetMap = this.parent.parent;
            // zoomX(),zoomY()是镜头聚焦的点
            //屏幕整体坐标 = 原始坐标 - 1 * $gameScreen.zoomX() * zoom + Graphics.boxWidth / 2;
            var screenX = -1 * $gameScreen.zoomX() * zoom + Graphics.boxWidth / 2;
            var screenY = -1 * $gameScreen.zoomY() * zoom + Graphics.boxHeight / 2;
            if (clamp && zoom >= 1.0) {
                var clampX1 = -Graphics.boxWidth * zoom + Graphics.boxWidth;
                var clampY2 = -Graphics.boxHeight * zoom + Graphics.boxHeight;
                this.x = (picX - Math.round($gameScreen.shake()) - Math.round(screenX.clamp(clampX1, 0))) / zoom;
                this.y = (picY - Math.round(screenY.clamp(clampY2, 0))) / zoom;
            } else if (clamp && zoom < 1.0) {
                this.x = (picX - Math.round($gameScreen.shake()) - Math.round((Graphics.boxWidth - Graphics.boxWidth * zoom) / 2)) / zoom;
                this.y = (picY - Math.round((Graphics.boxHeight - Graphics.boxHeight * zoom) / 2)) / zoom;
            } else {
                this.x = (picX - Math.round($gameScreen.shake()) - Math.round(screenX)) / zoom;
                this.y = (picY - Math.round(screenY)) / zoom;
            }
        }
    // 平时：Drill_LayerCamera
    }else{
        this.x -= $gameScreen.shake();  //平衡屏幕震动（不知道放这里对不对）
        if(!this.parent) {return;}
        if(!this.parent.parent) {return;}
        const spritesetMap = this.parent.parent;
        const rotation = spritesetMap._drill_LCa_change_rotation;
        const scale_x = spritesetMap._drill_LCa_change_sizeX;
        const scale_y = spritesetMap._drill_LCa_change_sizeY;
        if( rotation == 0 && scale_x == 1 && scale_y == 1 ){ return; } 

        const fix_point = $gameTemp.drill_LCa_getFixPointInAnchor( 0,0, 0.5,0.5, Graphics.boxWidth,Graphics.boxHeight, rotation, scale_x, scale_y );

        this.x -= Graphics.boxWidth/2/scale_x;	
        this.y -= Graphics.boxHeight/2/scale_y;	
        this.x -= fix_point.x/scale_x;
        this.y -= fix_point.y/scale_y;
    }
};

Sprite_Picture.prototype.updateScale = function() {
    const picture = this.picture();
    // 战斗中：YEP_X_ActSeqPack3
    if($gameParty.inBattle()) {
        if(ConfigManager.battleCamera){
            var zoom = $gameScreen.zoomScale();
            this.scale.x = picture.scaleX() / zoom / 100;
            this.scale.y = picture.scaleX() / zoom / 100;
 
        }else{
            this.scale.x = picture.scaleX() / 100;
            this.scale.y = picture.scaleY() / 100;
        }
    // 平时：Drill_LayerCamera
    } else {
        this.scale.x = picture.scaleX() / $gameSystem.drill_LCa_curScaleX() / 100;
        this.scale.y = picture.scaleY() / $gameSystem.drill_LCa_curScaleY() / 100;
    }
};


Sprite_Picture.prototype.updateOther = function() {
    var picture = this.picture();
    this.opacity = picture.opacity();
    this.blendMode = picture.blendMode();
    // 旋转时为0
    if(!!SceneManager._scene._spriteset){
        if(!!SceneManager._scene._spriteset.rotation){
            this.opacity = 0;
        }
    }
};